/*
 * @Author: lg
 * @Date: 2023-11-08 09:06:52
 * @LastEditors: zhouxuan
 * @LastEditTime: 2024-08-20 09:14:43
 * @Description:
 * @FilePath: \vite-react\src\router\index.jsx
 */
import { Suspense, lazy } from 'react';

import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';

// 路由懒加载
const Layout = lazy(() => import('@/views/layout/index'));

const Home = lazy(() => import('@/views/home/index'));
const NotFound = lazy(() => import('@/views/not-find/index'));
const AboutUs = lazy(() => import('@/views/about-us/index'));
const Introduction = lazy(() => import('@/views/about-us/introduction/index'));
const DevelopmentHistory = lazy(() =>
  import('@/views/about-us/development-history/index')
);

const CompanyNews = lazy(() =>
  import('@/views/news-center/company-news/major/index')
);
const CompanyNewsDetail = lazy(() =>
  import('@/views/news-center/company-news/detail/index')
);

const NewsCenter = lazy(() =>
  import('@/views/news-center/index')
);
const IndustryNews = lazy(() =>
  import('@/views/news-center/industry-news/index')
);

const EnterpriseCulture = lazy(() =>
  import('@/views/enterprise-culture/index')
);
const ContactUs = lazy(() => import('@/views/contact-us/index'));

//使用useRoutes简化写法

export const routes = [
  { path: '/', element: <Navigate to="/home" /> },
  {
    path: '/',
    element: <Layout />,
    children: [
      { path: 'home', title: '首页', element: <Home /> },
      {
        path: 'about-us',
        title: '关于我们',
        element: <AboutUs />,
        children: [
          {
            path: 'introduction',
            title: '公司简介',
            element: <Introduction />
          },
          {
            path: 'development-history',
            title: '发展历程',
            element: <DevelopmentHistory />
          }
        ]
      },
      {
        path: 'news-center',
        title: '新闻中心',
        element: <NewsCenter />,
        children: [
          {
            path: 'company-news',
            title: '公司动态',
            element: <CompanyNews />
          },
          {
            path: 'industry-news',
            title: '行业动态',
            element: <IndustryNews />
          }
        ]
      },
      {
        path: 'enterprise-culture',
        title: '企业文化',
        element: <EnterpriseCulture />
      },
      { path: 'contact-us', title: '联系我们', element: <ContactUs /> },
      {
        path: 'news-center/company-news/company-news-detail/:id',
        title: '公司动态详情',
        element: <CompanyNewsDetail />
      },
    ]
  },
  { path: '/not-find', element: <NotFound /> }
];
